#include "stdafx.h"
#include "TestXTaskDialog.h"
#include "TestDialogDlg.h"
#include "XTaskDialogClient.h"
#include "XTaskDialogMFCClient.h"


class CTestTaskDialogClient : public CXTaskDialogMFCClient
{
public:
  CTestTaskDialogClient() : m_bDisplayingPage2(FALSE)
  {
    m_Page2.SetMainInstructionText(_T("Main Instruction Text"));
    m_Page2.SetCommonButtons(TDCBF_OK_BUTTON | TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON | TDCBF_RETRY_BUTTON | TDCBF_CLOSE_BUTTON);
    m_Page2.ModifyFlags(0, TDF_ALLOW_DIALOG_CANCELLATION | TDF_POSITION_RELATIVE_TO_WINDOW);
    m_Page2.SetVerificationText(_T("This is the text for your Don't Remind Me Again type check box!"));
    m_Page2.ModifyFlags(0, TDF_NO_DEFAULT_RADIO_BUTTON | TDF_VERIFICATION_FLAG_CHECKED | TDF_CALLBACK_TIMER | TDF_USE_COMMAND_LINKS | TDF_SHOW_PROGRESS_BAR | TDF_EXPAND_FOOTER_AREA);
    
    //Only try to demo hyperlinks on a Unicode build on Windows XP or later (because XTaskDialog uses SysLink controls for this support, which are only supported on CommCtrl v6 which is Unicode only on XP or later)
    BOOL bEnableHyperlinks = FALSE;
  #ifdef _UNICODE
    bEnableHyperlinks = IsWinXPOrLater();
    if (bEnableHyperlinks)
      m_Page2.ModifyFlags(0, TDF_ENABLE_HYPERLINKS); 
  #endif //#ifdef _UNICODE
    
    if (bEnableHyperlinks)
      m_Page2.SetExpandedInformationText(_T("This is where your detailed expanded information text goes. Notice that it can span across multiple lines. Also, the main instruction text above appears in a larger font and is blue. Also notice the support for \"Don't Remind me again\" type check boxes, a special footer area with optional icon, emulated command link buttons, the use of white and light gray colors to differentiate certain sections of the Task Dialog, support for a customizable progress bar control, support for hyperlinks and support for a set of radio buttons. Click <A HREF=\"http://www.naughter.com\">here</A> or email me at <A HREF=\"mailto:pjna@naughter.com\">pjna@naughter.com</A> for updates!"));
    else
      m_Page2.SetExpandedInformationText(_T("This is where your detailed expanded information text goes. Notice that it can span across multiple lines. Also, the main instruction text above appears in a larger font and is blue. Also notice the support for \"Don't Remind me again\" type check boxes, a special footer area with optional icon, emulated command link buttons, the use of white and light gray colors to differentiate certain sections of the Task Dialog, support for a customizable progress bar control and support for a set of radio buttons. Check http://www.naughter.com or email me at pjna@naughter.com for updates!"));

    m_Page2.SetContentText(_T("This is where the content text goes.\nHere is the second line."));

    m_Page2Taskbuttons[0].nButtonID = 146;
    m_Page2Taskbuttons[0].pszButtonText = L"&First Command Link Button\nThis is the detailed instructions for the first command link";
    m_Page2Taskbuttons[1].nButtonID = 541;
    m_Page2Taskbuttons[1].pszButtonText = L"&Second Command Link Button\nThis is some info\nfor the second command link button";
    m_Page2Taskbuttons[2].nButtonID = 542;
    m_Page2Taskbuttons[2].pszButtonText = L"&Third Command Link Button without any detailed text";
    m_Page2.SetButtons(m_Page2Taskbuttons, 3);
    m_Page2.SetDefaultButton(145);
    
    if (bEnableHyperlinks)  
      m_Page2.SetFooterText(_T("For more info about the author of CXTaskDialog, please see my web page at <A HREF=\"http://www.naughter.com\">http://www.naughter.com</A>"));
    else
      m_Page2.SetFooterText(_T("For more info about the author of CXTaskDialog, please see my web page at http://www.naughter.com"));
      
    m_Page2.SetMainIcon(TD_SHIELD_ICONT);
    m_Page2.SetFooterIcon(IDR_MAINFRAME);

    m_Page2RadioButtons[0].nButtonID = 149;
    m_Page2RadioButtons[0].pszButtonText = L"Radio Button 1";
    m_Page2RadioButtons[1].nButtonID = 150;
    m_Page2RadioButtons[1].pszButtonText = L"Radio Button 2";
    m_Page2RadioButtons[2].nButtonID = 151;
    m_Page2RadioButtons[2].pszButtonText = L"Radio Button 3";
    m_Page2.SetRadioButtons(m_Page2RadioButtons, 3, 0);
  }

  static BOOL IsWinXPOrLater() 
  {
     //Initialize the OSVERSIONINFOEX structure
     OSVERSIONINFOEX osvi;
     ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
     osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
     osvi.dwMajorVersion = 5;
     osvi.dwMinorVersion = 1;

     //Initialize the condition mask
     DWORDLONG dwlConditionMask = 0;
     BYTE byOP = VER_GREATER_EQUAL;
     VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, byOP);
     VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, byOP);

     //Perform the test
     return VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION, dwlConditionMask);
  }

protected:
  virtual void OnHyperlinkClicked(LPCTSTR pszHREF)
  {
    ShellExecute(m_hWnd, _T("open"), pszHREF, NULL, NULL, SW_SHOW);
  }
  
  virtual BOOL OnButtonClicked(int nButton)
  {
    if (nButton == 145)
    {
      m_bDisplayingPage2 = TRUE;
      NavigatePage(m_Page2.m_tc);
      return TRUE;
    }
    else
      return FALSE;
  }

  virtual BOOL OnTimer(DWORD dwTickCount)
  {
    int x = rand() % 18;
    if (x == 1)
      EnableRadioButton(149, rand() % 2);
    else if (x == 2)
      UpdateIcon(TDIE_ICON_MAIN, TD_WARNING_ICONT);
    else if (x == 3)
      UpdateIcon(TDIE_ICON_MAIN, TD_ERROR_ICONT);
    else if (x == 4)
      UpdateIcon(TDIE_ICON_MAIN, TD_INFORMATION_ICONT);
    else if (x == 5)
      UpdateIcon(TDIE_ICON_FOOTER, TD_WARNING_ICONT);
    else if (x == 6)
      UpdateIcon(TDIE_ICON_FOOTER, TD_ERROR_ICONT);
    else if (x == 7)
      UpdateIcon(TDIE_ICON_FOOTER, TD_INFORMATION_ICONT);
    else if (x == 8)
      UpdateIcon(TDIE_ICON_MAIN, MAKEINTRESOURCE(IDR_MAINFRAME));
    else if (x == 9)
      UpdateIcon(TDIE_ICON_FOOTER, MAKEINTRESOURCE(IDR_MAINFRAME));
    else if (x == 10)
      UpdateIcon(TDIE_ICON_MAIN, (LPTSTR) NULL);
    else if (x == 11)
      UpdateIcon(TDIE_ICON_FOOTER, (LPTSTR) NULL);
    else if (x == 12)
    {
      //CString sTime;
      //sTime.Format(_T("%d"), rand());
      //SetElementText(TDE_CONTENT, sTime);
    }
    else if (x == 13)
    {
      //CString sTime;
      //sTime.Format(_T("%d"), rand());
      //SetElementText(TDE_EXPANDED_INFORMATION, sTime);
    }
    else if (x == 14)
    {
      //CString sTime;
      //sTime.Format(_T("%d"), rand());
      //SetElementText(TDE_FOOTER, sTime);
    }
    else if (x == 15)
    {
      //CString sTime;
      //sTime.Format(_T("%d"), rand());
      //SetElementText(TDE_MAIN_INSTRUCTION, sTime);
      if (!m_bDisplayingPage2)
        SetButtonElevationRequiredState(145, rand() % 2);
    }
    else if (x == 16)
      UpdateIcon(TDIE_ICON_MAIN, TD_SHIELD_ICONT);
    else if (x == 17)
      UpdateIcon(TDIE_ICON_FOOTER, TD_SHIELD_ICONT);
      
    SetProgressBarPos(dwTickCount * 100 / 8000);
  
    return (dwTickCount > 8000) ? TRUE : FALSE;
  }
  
  
  CXTaskDialogMFCClient m_Page2;
  TASKDIALOG_BUTTON m_Page2RadioButtons[3];
  TASKDIALOG_BUTTON m_Page2Taskbuttons[3];
  BOOL m_bDisplayingPage2;
};


class CTestTaskDialogClient2 : public CXTaskDialogClient
{
  virtual void OnHyperlinkClicked(LPCWSTR pszHREF)
  {
    ShellExecute(m_hWnd, _T("open"), CW2T(pszHREF), NULL, NULL, SW_SHOW);
  }

  virtual BOOL OnTimer(DWORD dwTickCount)
  {
    int x = rand() % 18;
    if (x == 1)
      EnableRadioButton(149, rand() % 2);
    else if (x == 2)
      UpdateIcon(TDIE_ICON_MAIN, TD_WARNING_ICON);
    else if (x == 3)
      UpdateIcon(TDIE_ICON_MAIN, TD_ERROR_ICON);
    else if (x == 4)
      UpdateIcon(TDIE_ICON_MAIN, TD_INFORMATION_ICON);
    else if (x == 5)
      UpdateIcon(TDIE_ICON_FOOTER, TD_WARNING_ICON);
    else if (x == 6)
      UpdateIcon(TDIE_ICON_FOOTER, TD_ERROR_ICON);
    else if (x == 7)
      UpdateIcon(TDIE_ICON_FOOTER, TD_INFORMATION_ICON);
    else if (x == 8)
      UpdateIcon(TDIE_ICON_MAIN, MAKEINTRESOURCEW(IDR_MAINFRAME));
    else if (x == 9)
      UpdateIcon(TDIE_ICON_FOOTER, MAKEINTRESOURCEW(IDR_MAINFRAME));
    else if (x == 10)
      UpdateIcon(TDIE_ICON_MAIN, (LPWSTR) NULL);
    else if (x == 11)
      UpdateIcon(TDIE_ICON_FOOTER, (LPWSTR) NULL);
    else if (x == 12)
    {
      //CStringW sTime;
      //sTime.Format(L"%d", rand());
      //SetElementText(TDE_CONTENT, sTime);
    }
    else if (x == 13)
    {
      //CStringW sTime;
      //sTime.Format(L"%d", rand());
      //SetElementText(TDE_EXPANDED_INFORMATION, sTime);
    }
    else if (x == 14)
    {
      //CString sTime;
      //sTime.Format(L"%d", rand());
      //SetElementText(TDE_FOOTER, sTime);
    }
    else if (x == 15)
    {
      //CStringW sTime;
      //sTime.Format(L"%d", rand());
      //SetElementText(TDE_MAIN_INSTRUCTION, sTime);
      SetButtonElevationRequiredState(145, rand() % 2);
    }
    else if (x == 16)
      UpdateIcon(TDIE_ICON_MAIN, TD_SHIELD_ICON);
    else if (x == 17)
      UpdateIcon(TDIE_ICON_FOOTER, TD_SHIELD_ICON);
      
    SetProgressBarPos(dwTickCount * 100 / 8000);
  
    return (dwTickCount > 8000) ? TRUE : FALSE;
  }
};



IMPLEMENT_DYNAMIC(CTestDialogDlg, CDialog)

CTestDialogDlg::CTestDialogDlg(CWnd* pParent /*=NULL*/)	: CDialog(CTestDialogDlg::IDD, pParent)
{
}

CTestDialogDlg::~CTestDialogDlg()
{
}

void CTestDialogDlg::DoDataExchange(CDataExchange* pDX)
{
  //Let the base class do its thing
  CDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CTestDialogDlg, CDialog)
  ON_BN_CLICKED(IDC_BUTTON1, &CTestDialogDlg::OnBnClickedButton1)
  ON_BN_CLICKED(IDC_BUTTON2, &CTestDialogDlg::OnBnClickedButton2)
  ON_BN_CLICKED(IDC_BUTTON3, &CTestDialogDlg::OnBnClickedButton3)
END_MESSAGE_MAP()

void CTestDialogDlg::OnBnClickedButton1()
{
  CTestTaskDialogClient dlg;
  dlg.SetWindowTitle(_T("XTaskDialog, Task Dialogs on 98, ME, 2000, XP and 2003"));
  dlg.SetMainInstructionText(_T("This is the Main Instruction Text"));
  dlg.SetCommonButtons(TDCBF_YES_BUTTON | TDCBF_NO_BUTTON);
  dlg.ModifyFlags(0, TDF_CAN_BE_MINIMIZED | TDF_ALLOW_DIALOG_CANCELLATION);
  dlg.SetVerificationText(_T("This is the text for your Don't Remind Me Again type check box!"));
  dlg.ModifyFlags(0, TDF_NO_DEFAULT_RADIO_BUTTON | TDF_VERIFICATION_FLAG_CHECKED | TDF_CALLBACK_TIMER | TDF_USE_COMMAND_LINKS | TDF_SHOW_PROGRESS_BAR | TDF_POSITION_RELATIVE_TO_WINDOW);

  //Only try to demo hyperlinks on a Unicode build on Windows XP or later (because XTaskDialog uses SysLink controls for this support, which are only supported on CommCtrl v6 which is Unicode only on XP or later)
  BOOL bEnableHyperlinks = FALSE;
#ifdef _UNICODE
  bEnableHyperlinks = CTestTaskDialogClient::IsWinXPOrLater();
  if (bEnableHyperlinks)
    dlg.ModifyFlags(0, TDF_ENABLE_HYPERLINKS); 
#endif
  
  dlg.SetContentText(_T("This is the Content Text"));
 
  if (bEnableHyperlinks)
    dlg.SetExpandedInformationText(_T("This is where your detailed expanded information text goes. Notice that it can span across multiple lines. Also, the main instruction text above appears in a larger font and is blue. Also notice the support for \"Don't Remind me again\" type check boxes, a special footer area with optional icon, emulated command link buttons, the use of white and light gray colors to differentiate certain sections of the Task Dialog, support for a customizable progress bar control, support for hyperlinks and support for a set of radio buttons. Click <A HREF=\"http://www.naughter.com\">here</A> or email me at <A HREF=\"mailto:pjna@naughter.com\">pjna@naughter.com</A> for updates!"));
  else
    dlg.SetExpandedInformationText(_T("This is where your detailed expanded information text goes. Notice that it can span across multiple lines. Also, the main instruction text above appears in a larger font and is blue. Also notice the support for \"Don't Remind me again\" type check boxes, a special footer area with optional icon, emulated command link buttons, the use of white and light gray colors to differentiate certain sections of the Task Dialog, support for a customizable progress bar control and support for a set of radio buttons. Check http://www.naughter.com or email me at pjna@naughter.com for updates!"));

  TASKDIALOG_BUTTON buttons[3];
  buttons[0].nButtonID = 145;
  //buttons[0].pszButtonText = MAKEINTRESOURCE(IDS_BUTTON_CAPTION);
  buttons[0].pszButtonText = L"&First Command Link Button\nThis button will demonstrate support for TDM_NAVIGATE_PAGE handling";
  buttons[1].nButtonID = 541;
  //buttons[0].pszButtonText = MAKEINTRESOURCE(IDS_BUTTON_CAPTION);
  buttons[1].pszButtonText = L"&Second Command Link Button\nThis is some info\nfor the second command link button";
  buttons[2].nButtonID = 542;
  buttons[2].pszButtonText = L"&Third Command Link Button without any detailed text";
  dlg.SetButtons(buttons, 3);
  dlg.SetDefaultButton(145);
  if (bEnableHyperlinks)
    dlg.SetFooterText(_T("For more info about the author of CXTaskDialog, please see my web page at <A HREF=\"http://www.naughter.com\">http://www.naughter.com</A>"));
  else
    dlg.SetFooterText(_T("For more info about the author of CXTaskDialog, please see my web page at http://www.naughter.com"));
  dlg.SetMainIcon(TD_SHIELD_ICONT);
  //HICON hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  //dlg.SetMainIcon(IDR_MAINFRAME);
  //dlg.SetMainIcon(hIcon);
  dlg.SetFooterIcon(TD_INFORMATION_ICONT);
  //dlg.SetFooterIcon(IDR_MAINFRAME);
  //dlg.SetFooterIcon(hIcon);

  TASKDIALOG_BUTTON radioButtons[3];
  radioButtons[0].nButtonID = 149;
  radioButtons[0].pszButtonText = L"Radio Button 1";
  radioButtons[1].nButtonID = 150;
  radioButtons[1].pszButtonText = L"Radio Button 2";
  radioButtons[2].nButtonID = 151;
  radioButtons[2].pszButtonText = L"Radio Button 3";
  dlg.SetRadioButtons(radioButtons, 3, 149);
  
  HRESULT hr = dlg.DoModalEmulatedStatic();
  if (FAILED(hr))
  {
    CString sMsg;
    sMsg.Format(_T("The TaskDialog returned an error, Error Code:%X"), hr);
    AfxMessageBox(sMsg, MB_OK | MB_ICONEXCLAMATION);
  }
  TRACE(_T("EmulatedStatic: Button clicked %d\n"), dlg.GetButtonClicked());
}

void CTestDialogDlg::OnBnClickedButton2()
{
  CTestTaskDialogClient2 dlg;
  dlg.SetMainInstructionText(L"This is the Main Instruction Text");
  dlg.SetCommonButtons(TDCBF_OK_BUTTON | TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON | TDCBF_RETRY_BUTTON | TDCBF_CLOSE_BUTTON);
  dlg.ModifyFlags(0, TDF_ALLOW_DIALOG_CANCELLATION | TDF_POSITION_RELATIVE_TO_WINDOW);
  dlg.SetVerificationText(L"This is the text for your Don't Remind Me Again type check box!");
  dlg.ModifyFlags(0, TDF_NO_DEFAULT_RADIO_BUTTON | TDF_VERIFICATION_FLAG_CHECKED | TDF_CALLBACK_TIMER | TDF_USE_COMMAND_LINKS | TDF_SHOW_PROGRESS_BAR | TDF_EXPAND_FOOTER_AREA);

  //Only try to demo hyperlinks on a Unicode build on Windows XP or later (because XTaskDialog uses SysLink controls for this support, which are only supported on CommCtrl v6 which is Unicode only on XP or later)
  BOOL bEnableHyperlinks = FALSE;
#ifdef _UNICODE
  bEnableHyperlinks = CTestTaskDialogClient::IsWinXPOrLater();
  if (bEnableHyperlinks)
    dlg.ModifyFlags(0, TDF_ENABLE_HYPERLINKS); 
#endif
  
  if (bEnableHyperlinks)
    dlg.SetExpandedInformationText(L"This is where your detailed expanded information text goes. Notice that it can span across multiple lines. Also, the main instruction text above appears in a larger font and is blue. Also notice the support for \"Don't Remind me again\" type check boxes, a special footer area with optional icon, emulated command link buttons, the use of white and light gray colors to differentiate certain sections of the Task Dialog, support for a customizable progress bar control, support for hyperlinks and support for a set of radio buttons. Click <A HREF=\"http://www.naughter.com\">here</A> or email me at <A HREF=\"mailto:pjna@naughter.com\">pjna@naughter.com</A> for updates!");
  else
    dlg.SetExpandedInformationText(L"This is where your detailed expanded information text goes. Notice that it can span across multiple lines. Also, the main instruction text above appears in a larger font and is blue. Also notice the support for \"Don't Remind me again\" type check boxes, a special footer area with optional icon, emulated command link buttons, the use of white and light gray colors to differentiate certain sections of the Task Dialog, support for a customizable progress bar control and support for a set of radio buttons. Check http://www.naughter.com or email me at pjna@naughter.com for updates!");

  dlg.SetContentText(L"This is where the content text goes.\nHere is the second line.");

  TASKDIALOG_BUTTON buttons[3];
  buttons[0].nButtonID = 145;
  buttons[0].pszButtonText = L"&First Command Link Button\nThis is the detailed instructions for the first command link";
  buttons[1].nButtonID = 541;
  buttons[1].pszButtonText = L"&Second Command Link Button\nThis is some info\nfor the second command link button";
  buttons[2].nButtonID = 542;
  buttons[2].pszButtonText = L"&Third Command Link Button without any detailed text";
  dlg.SetButtons(buttons, 3);
  dlg.SetDefaultButton(145);
  
  if (bEnableHyperlinks)  
    dlg.SetFooterText(L"For more info about the author of CXTaskDialog, please see my web page at <A HREF=\"http://www.naughter.com\">http://www.naughter.com</A>");
  else
    dlg.SetFooterText(L"For more info about the author of CXTaskDialog, please see my web page at http://www.naughter.com");
    
  dlg.SetMainIcon(TD_SHIELD_ICON);
  //dlg.SetFooterIcon(IDR_MAINFRAME);
  dlg.SetFooterIcon(TD_INFORMATION_ICON);

  TASKDIALOG_BUTTON radioButtons[3];
  radioButtons[0].nButtonID = 149;
  radioButtons[0].pszButtonText = L"Radio Button 1";
  radioButtons[1].nButtonID = 150;
  radioButtons[1].pszButtonText = L"Radio Button 2";
  radioButtons[2].nButtonID = 151;
  radioButtons[2].pszButtonText = L"Radio Button 3";
  dlg.SetRadioButtons(radioButtons, 3, 0);
  
  int nButton = 0;
  int nRadioButton = 0;
  BOOL bVerificationFlagChecked = FALSE;
  HRESULT hr = dlg.DoModalEmulatedDLL(GetSafeHwnd(), &nButton, &nRadioButton, &bVerificationFlagChecked);
  if (FAILED(hr))
  {
    CString sMsg;
    sMsg.Format(_T("The TaskDialog returned an error, Error Code:%X"), hr);
    AfxMessageBox(sMsg, MB_OK | MB_ICONEXCLAMATION);
  }
  TRACE(_T("EmulatedDLL: Button clicked %d\n"), nButton);
}

void CTestDialogDlg::OnBnClickedButton3()
{
  CTestTaskDialogClient dlg;
  dlg.SetWindowTitle(_T("XTaskDialog, Task Dialogs on 98, ME, 2000, XP and 2003"));
  dlg.SetMainInstructionText(_T("This is the Main Instruction Text"));
  dlg.SetCommonButtons(TDCBF_YES_BUTTON | TDCBF_NO_BUTTON);
  dlg.ModifyFlags(0, TDF_CAN_BE_MINIMIZED | TDF_ALLOW_DIALOG_CANCELLATION);
  dlg.SetVerificationText(_T("This is the text for your Don't Remind Me Again type check box!"));
  dlg.ModifyFlags(0, TDF_NO_DEFAULT_RADIO_BUTTON | TDF_VERIFICATION_FLAG_CHECKED | TDF_CALLBACK_TIMER | TDF_USE_COMMAND_LINKS | TDF_SHOW_PROGRESS_BAR | TDF_POSITION_RELATIVE_TO_WINDOW);

  //Only try to demo hyperlinks on a Unicode build on Windows XP or later (because XTaskDialog uses SysLink controls for this support, which are only supported on CommCtrl v6 which is Unicode only on XP or later)
  BOOL bEnableHyperlinks = FALSE;
#ifdef _UNICODE
  bEnableHyperlinks = CTestTaskDialogClient::IsWinXPOrLater();
  if (bEnableHyperlinks)
    dlg.ModifyFlags(0, TDF_ENABLE_HYPERLINKS); 
#endif
  
  dlg.SetContentText(_T("This is the Content Text"));
  if (bEnableHyperlinks)
    dlg.SetExpandedInformationText(_T("This is where your detailed expanded information text goes. Notice that it can span across multiple lines. Also, the main instruction text above appears in a larger font and is blue. Also notice the support for \"Don't Remind me again\" type check boxes, a special footer area with optional icon, emulated command link buttons, the use of white and light gray colors to differentiate certain sections of the Task Dialog, support for a customizable progress bar control, support for hyperlinks and support for a set of radio buttons. Click <A HREF=\"http://www.naughter.com\">here</A> or email me at <A HREF=\"mailto:pjna@naughter.com\">pjna@naughter.com</A> for updates!"));
  else
    dlg.SetExpandedInformationText(_T("This is where your detailed expanded information text goes. Notice that it can span across multiple lines. Also, the main instruction text above appears in a larger font and is blue. Also notice the support for \"Don't Remind me again\" type check boxes, a special footer area with optional icon, emulated command link buttons, the use of white and light gray colors to differentiate certain sections of the Task Dialog, support for a customizable progress bar control and support for a set of radio buttons. Check http://www.naughter.com or email me at pjna@naughter.com for updates!"));


  TASKDIALOG_BUTTON buttons[3];
  buttons[0].nButtonID = 145;
  //buttons[0].pszButtonText = MAKEINTRESOURCE(IDS_BUTTON_CAPTION);
  buttons[0].pszButtonText = L"&First Command Link Button\nThis is the detailed instructions for the first command link";
  buttons[1].nButtonID = 541;
  //buttons[0].pszButtonText = MAKEINTRESOURCE(IDS_BUTTON_CAPTION);
  buttons[1].pszButtonText = L"&Second Command Link Button\nThis is some info\nfor the second command link button";
  buttons[2].nButtonID = 542;
  buttons[2].pszButtonText = L"&Third Command Link Button without any detailed text";
  dlg.SetButtons(buttons, 3);
  dlg.SetDefaultButton(145);
  if (bEnableHyperlinks)
    dlg.SetFooterText(_T("For more info about the author of CXTaskDialog, please see my web page at <A HREF=\"http://www.naughter.com\">http://www.naughter.com</A>"));
  else
    dlg.SetFooterText(_T("For more info about the author of CXTaskDialog, please see my web page at http://www.naughter.com"));
  dlg.SetMainIcon(TD_SHIELD_ICONT);
  //HICON hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  //dlg.SetMainIcon(IDR_MAINFRAME);
  //dlg.SetMainIcon(hIcon);
  dlg.SetFooterIcon(TD_INFORMATION_ICONT);
  //dlg.SetFooterIcon(IDR_MAINFRAME);
  //dlg.SetFooterIcon(hIcon);

  TASKDIALOG_BUTTON radioButtons[3];
  radioButtons[0].nButtonID = 149;
  radioButtons[0].pszButtonText = L"Radio Button 1";
  radioButtons[1].nButtonID = 150;
  radioButtons[1].pszButtonText = L"Radio Button 2";
  radioButtons[2].nButtonID = 151;
  radioButtons[2].pszButtonText = L"Radio Button 3";
  dlg.SetRadioButtons(radioButtons, 3, 149);
  
  HRESULT hr = dlg.DoModalNative();
  if (FAILED(hr))
  {
    CString sMsg;
    sMsg.Format(_T("The TaskDialog returned an error, Error Code:%X"), hr);
    AfxMessageBox(sMsg, MB_OK | MB_ICONEXCLAMATION);
  }
  TRACE(_T("Native: Button clicked %d\n"), dlg.GetButtonClicked());
}
